<template>
	<view style="padding: 30upx;">
		<view class="fundCard">
			<view class="fundCard-title">绑定银行卡账户</view>
			<view class="">
				<view class="fundCard-money">
					¥{{ bankpending_for_withdraw_amount || 0 }}
					<view class="fundCard-operation-tip" style="font-size: 20upx;">
						可提现
					</view>
					<!-- <view>.00</view> -->
				</view>
			</view>
			<view class="fundCard-money-text">可提现总额(元)</view>
			<view class="">
				<view class="fundCard-all-money">
					<view style="font-size: 36upx; font-weight: bold;">
						¥{{ banktotal || 0 }}
						<!-- <view style="display: inline-block; font-size: 28upx;">.00</view> -->
					</view>
					<view class="">总金额(元)</view>
					<view class="">总额扣除{{rate_up*100}}%手续费</view>
				</view>
				<view class="fundCard-wait-money">
					<view style="font-size: 36upx; font-weight: bold;">
						¥{{ bankpending_for_settlement_amount || 0 }}
						<!-- <view style="display: inline-block; font-size: 28upx;">.00</view> -->
					</view>
					<view class="">待结算(元)</view>
					<view class="">今日收款金额过24点提现</view>
				</view>
			</view>
			<view class="fundCard-money-btn" @click="goFundManage(2)">
				去提现到绑定银行卡
			</view>
		</view>
		<view class="fundCard" style="background-color: #FDCAAD;">
			<view class="fundCard-title">平台账户</view>
			<view class="">
				<view class="fundCard-money">
					¥{{ wxpending_for_withdraw_amount || 0 }}
					<view class="fundCard-operation-tip" style="font-size: 20upx;">
						可提现
					</view>
					<!-- <view>.00</view> -->
				</view>
			</view>
			<view class="fundCard-money-text">可提现总额(元)</view>
			<view class="">
				<view class="fundCard-all-money">
					<view style="font-size: 36upx; font-weight: bold;">
						¥{{ wxtotal || 0}}
						<!-- <view style="display: inline-block; font-size: 28upx;">.00</view> -->
					</view>
					<view class="">总金额(元)</view>
					<view class="">总额扣除{{rateWx * 100}}%手续费</view>
				</view>
				<view class="fundCard-wait-money">
					<view style="font-size: 36upx; font-weight: bold;">
						¥{{ wxpending_for_settlement_amount || 0 }}
						<!-- <view style="display: inline-block; font-size: 28upx;">.00</view> -->
					</view>
					<view class="">待结算(元)</view>
					<view class="">今日收款金额过24点提现</view>
				</view>
			</view>
			<view class="fundCard-money-btn" @click="goFundManage(1)">
				去提现到绑定个人微信
			</view>
		</view>
		<uni-popup ref="wechat" type="center" >
			<view class="" style="width: 60vw; background-color: #ffffff;">
				<view class="" style="text-align: center; padding: 40upx 20upx 40upx 20upx; border-bottom: 1upx solid #000000;">
					您还没有绑定银行卡
				</view>
				<view style="display: inline-block; padding: 4%; width: 41%; text-align: center; border-right: 1upx solid #000000;" @click="close">
					取消
				</view>
				<view style="display: inline-block; padding: 4%; width: 40%; text-align: center; color: #007AFF;" @click="setPayment(2)">
					去绑定
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	export default {
		data() {
			return {
				wxtotal: '',
				wxpending_for_settlement_amount: '',
				wxpending_for_withdraw_amount: '',
				banktotal: '',
				bankpending_for_settlement_amount: '',
				bankpending_for_withdraw_amount: '',
				isCard:'',
				store_id:'',
				rateWx:0,
				rate_up:0,
			}
		},
		onLoad(options) {
			let store_id = parseInt(options.store_id,10);
			console.log('进入了onload 获取url的store_id',store_id)
			this.store_id = parseInt(store_id,10)
		},
		onShow() {
			this.get_store_capital()
			this.isBindingCard()
		},
		methods: {
			isBindingCard(){
				let data = {
					token:this.$store.getters.getToken,
					store_id:this.store_id
				}
				this.$api.is_binding_card(data).then(res => {
					console.log(res)
					this.isCard = res.status
					if(res.status){
						// this.$store.commit('updataIndentId',res.res)
						// uni.setStorageSync('customer_store_identification_id',res.res)
						this.getBingindCard(res.res)
					}
				}).catch(err => {
					console.log(err)
				})
			},
			// 设置提现方式
			setPayment(valu){
				uni.navigateTo({
					url:'/pages/memberCenter/shop/BankCardBinding/BankCardBinding?page=bingind&store_id=' + this.store_id + '&valu=' + valu
				})
			},
			goFundManage(id){
				if( id == 1 ){
					uni.navigateTo({
						url:"fundManage?isd=" + id
					})
				}else if( id == 2 && this.isCard == false){
					this.$refs.wechat.open()
				}else if( id == 2 && this.isCard == true ){
					uni.navigateTo({ 
						url:"fundManage?isd=" + id
					})
				}
			},
			close(){
				this.$refs.wechat.close()
			},
			get_store_capital(){
				const that = this
				let data = {
					token:that.$store.getters.getToken,
				}
				that.$api.get_store_capital(data).then(res => {
					console.log(res,'get_store_capital')
					if(res.status){
						
						that.wxtotal = res.data.wx.total
						that.wxpending_for_settlement_amount = res.data.wx.pending_for_settlement_amount
						that.wxpending_for_withdraw_amount = res.data.wx.pending_for_withdraw_amount
						that.rateWx = res.storeInfo.rate_wx
						
						
						that.banktotal = res.data.bank.total
						that.bankpending_for_settlement_amount = res.data.bank.pending_for_settlement_amount
						that.bankpending_for_withdraw_amount = res.data.bank.pending_for_withdraw_amount
						if( res.storeInfo.is_huifu_up == 1 ){
							that.rate_up = res.storeInfo.rate_up
						}else{
							that.rate_up = res.storeInfo.rate_down
						}
					}else{
						
						uni.showToast({
							title:res.msg,
							icon:"none",
							duration:2000
						})
						
					}
					
				}).catch(err => {
					
					uni.showToast({
						title:err,
						icon:"none",
						duration:2000
					})
					
					console.log(err,'that.$api.get_store_income')
				})
			},
		}
	}
</script>

<style>
	.fundCard{
		width: 100%;
		height: 38vh;
		background-color: #F1D8A7;
		margin-bottom: 30upx;
		padding-top: 16upx;
		border-radius: 16upx;
		text-align: center;
	}
	.fundCard-title{
		font-size: 28upx;
		color: #723D13;
		font-weight: bold;
		margin-left: 18upx;
		text-align: left;
	}
	.fundCard-money{
		font-family: DINAlternate-Bold;
		font-size: 80upx;
		/* margin-bottom: 10upx; */
		color: #E41D1D;
		text-align: center;
		/* margin-top: 10upx; */
		text-shadow: 0 4upx 8upx rgba(228,29,29,0.15);
	}
	.fundCard-money>view{
		display: inline-block;
		font-size: 40upx;
	}
	.fundCard-money-text{
		text-align: center;
		font-size: 24upx;
		color: #EC3800;
		font-weight: bold;
		margin-bottom: 10upx;
	}
	.fundCard-operation-tip{
		position: absolute;
		color: #FFFFFF;
		padding: 0 10upx;
		background: #FF391F;
		border-radius: 14upx 14upx 14upx 0;
		text-align: center;
	}
	.fundCard-all-money{
		display: inline-block;
		width: 50%;
		color: #953B1F;
		font-size: 24upx;
		text-align: center;
		border-right: 1upx solid #953B1F;
	}
	.fundCard-wait-money{
		display: inline-block;
		width: 49%;
		color: #953B1F;
		font-size: 24upx;
		text-align: center;
	}
	.fundCard-money-btn{
		width: 400upx;
		margin-top: 20upx;
		font-size: 30upx;
		padding: 10upx 0;
		margin-left: 144upx;
		color: rgba(255,255,255,1);
		border-radius: 80upx;
		background-image: linear-gradient(90deg, #FE9543 14%, #FF664F 100%);
	}
</style>
